<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">
            <ui:define name="content">

                <h:form >

                    <p:panel>
                        <p:panelGrid columns="2">
                            <p:outputLabel value="Investigations"></p:outputLabel>
                            <p:autoComplete widgetVar="aPt" id="acPt" forceSelection="true" converter="ixcon"
                                            value="#{investigationValidatorComponentController.currentInvestigation}" 
                                            completeMethod="#{investigationController.completeInvest}" 
                                            var="apt" itemLabel="#{apt.name}" 
                                            itemValue="#{apt}" size="30"  style="width: 400px;">
                               
                                <p:column>
                                    #{apt.name}
                                </p:column>
                                <p:column>
                                    #{apt.fullName}
                                </p:column>
                                <p:column>
                                    #{apt.department.name}
                                </p:column>
                                <f:ajax listener="#{investigationValidatorComponentController.listItemValidator()}" render="invalcom" event="itemSelect" execute="acPt"></f:ajax>
                            </p:autoComplete> 
                            <p:outputLabel value="Item Validators"></p:outputLabel>
                            <h:selectOneMenu value="#{investigationValidatorComponentController.currentValidator}" id="invalcom" converter="investigationValidatorConverter">
                                <f:selectItems var="iv"  itemLabel="#{iv.name}" itemValue="#{iv}" 
                                               value="#{investigationValidatorComponentController.investigationItemValidators}"></f:selectItems>
                                <f:ajax execute="@this" render="panelDetails" ></f:ajax>
                            </h:selectOneMenu>

                            <p:panel id="panelDetails" >
                                <p:outputLabel value="Maximum Value"  rendered="#{investigationValidatorController.current ne null}"></p:outputLabel>
                                <p:inputText value="#{investigationValidatorController.current.maximumValue}" rendered="#{investigationValidatorController.current ne null}"></p:inputText>
                                <p:outputLabel value="Minimum Value"  rendered="#{investigationValidatorController.current ne null}"></p:outputLabel>
                                <p:inputText value="#{investigationValidatorController.current.minimumValue}"  rendered="#{investigationValidatorController.current ne null}"></p:inputText>
                                <p:commandButton ajax="false" value="Save" action="#{investigationValidatorController.updateValidator()}"></p:commandButton>
                            </p:panel>

                        </p:panelGrid>
                        <div align="center">
                            <p:panelGrid columns="2">
                                <p:outputLabel value="New Validator"></p:outputLabel>
                                <p:inputText value="#{investigationValidatorComponentController.newValidatorName}"></p:inputText>
                                <p:commandButton ajax="false" action="#{investigationValidatorComponentController.addNewValidator()}" value="Save"></p:commandButton>
                            </p:panelGrid>
                        </div>
                        <p:panel>
                            <f:facet name="Add component"></f:facet>
                            <p:panelGrid columns="2">
                                <p:inputText></p:inputText>
                                <p:commandButton value="Add"></p:commandButton>
                            </p:panelGrid>
                        </p:panel>
                    </p:panel>
                </h:form>
            </ui:define>

        </ui:composition>

    </h:body>
</html>
